<template>
    <el-dialog
        :visible.sync="dialogVisible"
        title="资金明细管理"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
        width="500px"
    >
        <el-form ref="formRef" :model="formData" :rules="rules" label-width="80px">

            <el-form-item label="用户id" prop="uid">
                <el-input v-model="formData.uid" placeholder="请输入" readonly/>
            </el-form-item>
            <el-form-item label="提现金额" prop="amount">
                <el-input v-model="formData.amount" placeholder="请输入" readonly/>
            </el-form-item>
            <el-form-item label="银行账号" prop="bankAccountNumber">
                <el-input v-model="formData.bankAccountNumber" placeholder="请输入" readonly/>
            </el-form-item>
            <el-form-item label="银行户名" prop="bankAccountName">
                <el-input v-model="formData.bankAccountName" placeholder="请输入" readonly/>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
                <el-input v-model="formData.remark" placeholder="请输入"/>
            </el-form-item>
            <el-form-item label="交易号" prop="outTradeNo">
                <el-input v-model="formData.outTradeNo" placeholder="请输入"/>
            </el-form-item>
            <el-form-item label="申请结果" prop="result">
                <el-radio-group v-model="formData.result">
                    <el-radio label="1">同意</el-radio>
                    <el-radio label="2">拒绝</el-radio>
                </el-radio-group>
            </el-form-item>

        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false" style="margin-right: 20px;">取 消</el-button>
            <el-popconfirm title="确定保存吗？" @onConfirm="submitForm()">
                <el-button slot="reference" type="primary">保存</el-button>
            </el-popconfirm>
        </div>
    </el-dialog>
</template>

<script>
import {WithdrawDepositApi} from '@/api/user/WithdrawDepositApi'

export default {
    name: 'UserWithdrawDepositUpdate',
    components: {},
    data() {
        return {
            formData: {
                id: '',
                uid: '',
                amount: '',
                bankAccountNumber: '',
                bankAccountName: '',
                remark: '',
                outTradeNo:'',
                result: '',
            },
            rules: {
                result: [
                    {required: true, message: '请输入申请结果', trigger: 'blur'}
                ],
            },
            dialogVisible: false
        }
    },
    created() {
    },
    methods: {
        // 显示组件
        async showUpdate(id) {
            const that = this

            that.dialogVisible = true
            if (that.$refs['formRef'] !== undefined) {
                that.$refs['formRef'].resetFields()
            }

            that.$nextTick(() => {
                if (id > 0) {
                    WithdrawDepositApi.load(id).then((response) => {
                        that.formData = Object.assign({}, response)
                    })
                }
            })
        },

        // 提交表单
        submitForm() {
            const that = this
            that.$refs['formRef'].validate((valid) => {
                if (!valid) return false
                WithdrawDepositApi.edit(that.formData).then(() => {
                    that.dialogVisible = false
                    that.$emit('refresh')
                })
            })
        }
    }
}
</script>


